/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2019
 */

package com.jzwl.site.manager.complaint.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.jzwl.common.page.PageObject;
import com.jzwl.site.manager.complaint.service.BusinessCircleComplaintService;
import com.jzwl.system.base.controller.BaseController;

/**
 * BusinessCircleComplaint
 * BusinessCircleComplaint
 * businessCircleComplaint
 * <p>Title:BusinessCircleComplaintController </p>
 * 	<p>Description:BusinessCircleComplaint </p>
 * 	<p>Company: </p> 
 * 	@author aotu-code 
 */
@Controller
@RequestMapping("/complaint")
public class BusinessCircleComplaintController extends BaseController {

	@Autowired
	private BusinessCircleComplaintService businessCircleComplaintService;

	/**
	 * 跳转到添加BusinessCircleComplaint
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/toAddBusinessCircleComplaint")
	public String toAddBusinessCircleComplaint(HttpServletRequest request, HttpServletResponse response, Model model) {

		model.addAttribute("url", "v2businessCircleComplaint/addBusinessCircleComplaint.html");
		return "/v2/jsp/businessCircleComplaint/businessCircleComplaintform";

	}

	/**
	 * 添加BusinessCircleComplaint
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/addBusinessCircleComplaint")
	public String addBusinessCircleComplaint(HttpServletRequest request, HttpServletResponse response, Model model) {

		try {
			createParameterMap(request);
			boolean flag = businessCircleComplaintService.addBusinessCircleComplaint(paramsMap);
			if (flag) {
				model.addAttribute("msg", "添加成功");
				return "redirect:/v2businessCircleComplaint/businessCircleComplaintList.html?start=0";
			} else {
				model.addAttribute("msg", "添加失败");
				return "/error";
			}
		} catch (Exception e) {
			e.printStackTrace();
			model.addAttribute("msg", "添加失败");
			return "/error";
		}

	}

	/**
	 * 跳转到修改页面
	 * @param request
	 * @param response
	 */
	@RequestMapping(value = "/toUpdateBusinessCircleComplaint")
	public String toUpdateBusinessCircleComplaint(HttpServletRequest request, HttpServletResponse response, Model model) {

		try {
			createParameterMap(request);
			Map<String, Object> objMap = businessCircleComplaintService.getById(paramsMap);
			model.addAttribute("objMap", objMap);
			return "/manager/complaint/detail";

		} catch (Exception e) {
			e.printStackTrace();
			model.addAttribute("msg", "获取数据失败");
			return "/error";
		}

	}

	/**
	 * 修改businessCircleComplaint
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/updateBusinessCircleComplaint")
	public String updateBusinessCircleComplaint(HttpServletRequest request, HttpServletResponse response, Model model) {

		try {
			createParameterMap(request);
			boolean flag = businessCircleComplaintService.updateBusinessCircleComplaint(paramsMap);

			if (flag) {
				return "redirect:/v2businessCircleComplaint/businessCircleComplaintList.html?start=0";
			} else {
				model.addAttribute("msg", "保存失败");
				return "/error";
			}
		} catch (Exception e) {

			e.printStackTrace();
			model.addAttribute("msg", "保存失败");
			return "/error";
		}
	}

	/**
	 * businessCircleComplaintlist
	 */
	@RequestMapping(value = "/businessCircleComplaintList")
	public String businessCircleComplaintList(HttpServletRequest request, HttpServletResponse response, Model model) {

		try {
			createParameterMap(request);
			PageObject po = new PageObject();
			po = businessCircleComplaintService.queryBusinessCircleComplaintList(paramsMap);
			model.addAttribute("po", po);
			model.addAttribute("paramsMap", paramsMap);
			return "/manager/complaint/list";
		} catch (Exception e) {
			e.printStackTrace();
			model.addAttribute("msg", "获取数据失败");
			return "/error";
		}

	}

	/**
	 * 删除businessCircleComplaint
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/deleteBusinessCircleComplaint")
	public String deleteBusinessCircleComplaint(HttpServletRequest request, HttpServletResponse response, Model model) {

		try {
			createParameterMap(request);

			boolean flag = businessCircleComplaintService.deleteBusinessCircleComplaint(paramsMap);

			if (flag) {
				return "redirect:/v2businessCircleComplaint/businessCircleComplaintList.html?start=0";
			} else {
				model.addAttribute("msg", "删除失败");
				return "/error";
			}
		} catch (Exception e) {
			e.printStackTrace();
			model.addAttribute("msg", "删除失败");
			return "/error";
		}

	}

	//auto-code-end

}
